home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 14610 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: news.mira.net.au!news
  2. From: davidw@werple.net.au (David White)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: HELP: Getting the address of member functions
  5. Date: 1 Apr 1996 20:10:32 +1000
  6. Organization: Werple Internet, Melbourne
  7. Message-ID: <4joa2o$7a9@werple.net.au>
  8. References: <4jndbi$m12@lucy.swin.edu.au>
  9. NNTP-Posting-Host: werplez.mira.net.au
  10.  
  11. 079519@bud.swin.edu.au (John Joseph Newbigin) writes:
  12.  
  13. >I am writing a serial port driver class in BC3.1.  It is interrupt driven so I 
  14. >need an interrupt function that can be set to the required int. vector.  I can do 
  15. >this using a normal function but it can not access the class data and so needs 
  16. >global vars. and hence, defeats the purpose of a class.
  17.  
  18. >Does anyone know how to get the address of member functions so I can overcome this 
  19. >problem?
  20.  
  21. You have to use a static or global variable. Remember that a non-static
  22. member function serves all instances of the class. Therefore, it needs to
  23. know when it is called which instance it is being called for. This is done
  24. by an implicit argument, the instance's address ('this'), being passed to
  25. it. Since the processor only knows the interrupt handler's address, not
  26. the instance address as well, it cannot call the member function in the
  27. way it requires. 
  28.  
  29. David White
  30. davidw@werple.mira.net.au
  31.